home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / Snippets / Toolbox / ReKeyTransƒ / KillDeadKeys.a next >
Encoding:
Text File  |  1992-07-15  |  2.3 KB  |  85 lines  |  [TEXT/MPS ]

  1. ***********************************************************************
  2. ***
  3. ***        Patch KeyTrans AKA Dead Key Killer
  4. ***
  5. ***********************************************************************
  6.  
  7.                     STRING    ASIS
  8.                     PRINT    OFF
  9.                     INCLUDE 'Traps.a'
  10.                     INCLUDE 'SysEqu.a'
  11.                     PRINT    ON
  12.                     
  13.  
  14.  
  15. KeyTrans        EQU        $A9C3
  16.  
  17. ******************************** Entry *******************************
  18.  
  19. PatchKeyTrans    PROC        EXPORT
  20.  
  21.         EXPORT        OrigAddr
  22.  
  23.         bra.s        theDude
  24.  
  25. ******************************** MyKeyTrans *******************************
  26.  
  27. MyKeyTrans
  28.         bset.b        #7,9(sp)            ;set the up/down bit - KeyTrans won't process
  29.                                         ; "dead" up strokes. Currently, this does not
  30.                                         ; affect the event record up/down state.
  31.         move.l        OrigAddr,-(sp)        ;push original KeyTrans address
  32.         rts                                ; and rts to it
  33.  
  34. OrigAddr    DC.L    0                    ;a place for the old KeyTrans address
  35.         
  36. KTEnd
  37.  
  38. ******************************** MainDude *******************************
  39.  
  40. UnImpTrap        EQU        $A89F
  41.  
  42. theDude    
  43.  
  44.         movem.l        d0/a0-a2,-(sp)            ;save some regs
  45.         move.l        #KTEnd-MyKeyTrans,d0    ;size up a block for the sys heap
  46.         _newPtr        ,Clear                    ;clean bytes, please
  47.         bne.s        abort                    ;if'n it didn't work, give up
  48.         move.l        a0,a2                    ;keep our new ptr around for later
  49.         
  50.         move.w        #KeyTrans,d0            ;get trap word of KeyTrans
  51.         _GetTrapAddress        ,NEWTOOL        ;get the original address
  52.         bne.s        abort                    ;if error, bail out - this shouldn't happen
  53.         lea            OrigAddr,a1                ;point to our storage
  54.         move.l        a0,(a1)                    ;save old address
  55.         beq.s        abort                    ;abort if not a valid pointer
  56.         
  57.         movea.l        a2,a1                    ;set up destination ptr for blockmove
  58.         lea            MyKeyTrans,a0            ;set up source ptr for blockmove
  59.         move.l        #KTEnd-MyKeyTrans,d0    ;size up hpw many bytes to move
  60.         _blockMove                            ;and moof 'em
  61.         
  62.         movea.l        a2,a0                    ;get a pointer to our routine
  63.         move.w        #KeyTrans,d0            ;get trap word of KeyTrans
  64.         _SetTrapAddress        ,NEWTOOL        ;set to our routine
  65.         
  66. exit    movem.l        (sp)+,d0/a0-a2            ;restore some regs
  67.         rts
  68. abort    _debugger
  69.         rts
  70.         
  71.         ENDP
  72.         
  73. UnPatch        PROC        EXPORT
  74.  
  75.         IMPORT        OrigAddr
  76.  
  77.     
  78.         movem.l        d0/a0,-(sp)                ;save some regs
  79.         movea.l        OrigAddr,a0                ;get a pointer to original routine
  80.         move.w        #KeyTrans,d0            ;get trap word of KeyTrans
  81.         _SetTrapAddress        ,NEWTOOL        ;set to original routine
  82.         movem.l        (sp)+,d0/a0                ;restore some regs
  83.         rts
  84.         
  85.         END